// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import QtQuick.Layouts

import Fk
import Fk.Components.Common
import "choiceBoxComponents" as ChoiceComponents

ChoiceComponents.ChoiceBg {
  property var options: []
  property var all_options: []
  property string skill_name: ""
  property int result

  id: root
  title.text: Lua.tr("$Choice").arg(Lua.tr(skill_name))
  width: Math.max(140, body.width + 20)
  height: body.height + title.height + 20

  GridLayout {
    id: body
    x: 10
    y: title.height + 5
    flow: GridLayout.TopToBottom
    rows: 8
    columnSpacing: 10

    Repeater {
      model: all_options

      ChoiceComponents.ChoiceItem {
        Layout.fillWidth: true
        text.text: Util.processPrompt(modelData)
        enabled: options.indexOf(modelData) !== -1

        img.source: Cpp.path + "/packages/lunarltk-qsgs-ui/image/selfArea/choiceBox/choice-button-2.png"
        img.border.left: 6
        img.border.right: 6
        img.border.top: 5
        img.border.bottom: 6

        onClicked: {
          result = index;
          root.close();
        }
      }
    }
  }
}
